package com.example.sql;

import com.example.bean.Student;
import org.apache.ibatis.jdbc.SQL;

/**
 * @program: mybatis_maven
 * @description:
 * @author: zhanghz001
 * @create: 2020-11-11 08:40
 **/
public class ReturnSql {
    public String getSelectAll() {
        return new SQL() {
            {
                SELECT("*");
                FROM("student");
            }
        }.toString();
    }

    public String getInsert(Student student) {
        return new SQL() {
            {
                INSERT_INTO("student(id, NAME, age)");
                INTO_VALUES("#{id},#{name},#{age}");
            }
        }.toString();

    }

    public String getUpdate(Student student) {
        return new SQL() {
            {
                UPDATE("student");
                SET("NAME=#{name}", "age=#{age}");
                WHERE("id=#{id}");
            }
        }.toString();

    }

    public String getSelectById(Integer id) {
        return new SQL() {
            {
                SELECT("*");
                FROM("student");
                WHERE("id=#{id}");
            }
        }.toString();

    }

    public String getDelete(Integer id) {
        return new SQL() {
            {
                DELETE_FROM("student");
                WHERE("id=#{id}");
            }
        }.toString();

    }

}
